package at.fhj.swd.pse.gui.pageobjects;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import at.fhj.swd.pse.gui.drivers.GuiTestBaseSeleniumJava4Webdriver;

public class CommunityDetailPage extends GuiTestBaseSeleniumJava4Webdriver {
	private final GuiTestBaseSeleniumJava4Webdriver webdriver = new GuiTestBaseSeleniumJava4Webdriver();

	public GuiTestBaseSeleniumJava4Webdriver getWebdriver() {
		return this.webdriver;
	}

	public CommunityDetailPage() throws Exception {
		this.open();

	}

	public void open() throws Exception {
		this.webdriver.start();
		this.webdriver.getDriver().get(this.webdriver.getBaseUrl());
		this.webdriver.getDriver().findElement(By.linkText("Communitydetails*")).click();

	}

	public void close() throws Exception {
		this.webdriver.end();
	}

	public boolean insertNewUser(final String regExpSearchString) throws Exception {

		this.webdriver.getDriver().findElement(By.id("j_idt7:asForm:enter")).click();

		WebElement dynamicElement = new WebDriverWait(this.webdriver.getDriver(), 10).until(ExpectedConditions.presenceOfElementLocated(By.id("loginOutputLabel")));
		return dynamicElement.getText().startsWith(regExpSearchString);
	}

}
